<?php
// 本类由系统自动生成，仅供测试用途
namespace Home\Controller;
use Think\Controller;
class IndexController extends Controller {
    public function index(){	
    	$urllink = M("urllink");
		$arr = $urllink->select();
		$this->assign("lin",$arr);
		$Ann = M("Ann");
		$ar = $Ann->select();
		$this->assign("arr",$ar);
		
		
		
		$this->display();
    }
    public function lists(){
		 $a=I('get.id');
    	$data="cate_id=$a";
    	$info=M('goods')->where($data)->select();
    	
    	$this->assign('info',$info);// 赋值分页输出
    	$this->display();
    }
    public function shpy(){
    	 	$a=I('get.id');
    
    	$info=M('goods')->find($a);
    	$data=explode(',',$info['goods_attr_pic']);
    
    	$this->assign('info',$info);// 赋值分页输出
    	$this->assign('data',$data);// 赋值分页输出
    	
    	$this->display();
    }

	public function proquery(){
		$pid = I("get.pid");
		$num = I("get.num");
		$desc = I("get.desc");
		$res = M("goods")->find($pid);
		$arr["uname"] = $_session["uname"];
		$arr["goods_name"] = $res["goods_name"];
		$arr["pro_img"] = $res["goods_pic"];
		$arr["goods_desc"] = $res["goods_desc"];
		$arr["goods_price"] = $res["goods_price"];
		$arr["pid"] = $res["id"];
		//$arr["goods_size"] = $res["size"];/////////
		//$arr["goods_color"] = $res["color"];////////
		$arr["goods_tc_desc"] = $desc;	
		$arr["goods_num"] = $num;
		$arr["goods_pnum"] = $res["goods_num"];
		$r = array();
		if( D('showcar')->add($arr)){
			$re = M("showcar")->where("status=0")->select();
			$m = count($re);
			foreach($re as $v){
				$price =$v["goods_num"]*$v["goods_price"];
				$total +=$price;
			}
			$r['status']=true;
			$r['m'] = $m;
			$r['total'] = $total;
		}else{
			$r['status']=false;
		}
		$this->ajaxReturn($r);
	 }
  }